package com.example.leetdemo.plan1;

import java.util.Arrays;
import java.util.List;

public class Sword035 {

    public int findMinDifference(List<String> timePoints) {
        if (timePoints.size() == 0) {
            return 0;
        }
        int[] times = new int[timePoints.size() + 1];
        int i = 0;
        for (String time : timePoints) {
            times[i] = Integer.parseInt(time.substring(0, 2)) * 60 + Integer.parseInt(time.substring(3, 5));
            i++;
        }
        times[i] = 1000007;
        Arrays.sort(times);
        times[i] = times[0] + 24 * 60;
        int min = 1000007;
        for (i = 1; i < times.length; i++) {
            min = Math.min(times[i] - times[i - 1], min);
            if (min == 0) {
                return 0;
            }
        }
        return min;
    }
}
